<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:pe="http://primefaces.org/ui/extensions">

    <ui:define name="content">
        <h:outputStylesheet library="css" name="printing.css"></h:outputStylesheet>
        <h:form>
            <p:panel>
                <h:panelGrid columns="2">
                    <h:outputLabel value="From Date"/>
                    <p:calendar value="#{bookKeepingSummery.fromDate}" navigator="true" pattern="dd MMMM yyyy HH:mm:ss"  >
                    </p:calendar>
                    <h:outputLabel value="To Date"/>
                    <p:calendar value="#{bookKeepingSummery.toDate}" navigator="true" pattern="dd MMMM yyyy HH:mm:ss" >
                    </p:calendar>
                    <h:outputLabel value="Instituion"/>
                    <p:autoComplete styleClass="noPrintButton"  value="#{bookKeepingSummery.institution}"  
                                      completeMethod="#{institutionController.completeCompany}" var="dept" itemValue="#{dept}" itemLabel="#{dept.name}" forceSelection="true" rendered="true" requiredMessage="You must select a department" >
                    </p:autoComplete>

                </h:panelGrid>

                <h:panelGrid columns="4">
                    <p:spacer height="1" width="80"/>
                    <p:commandButton ajax="false" value="Process" action="#{bookKeepingSummery.createLabSummeryInward}"/>
                    <p:commandButton ajax="false" value="Excel" actionListener="#{bookKeepingSummery.createLabSummeryInward}" styleClass="noPrintButton" style="float: right;" >
                        <pe:exporter type="xlsx" target="sum1" fileName="report_pharmacy_sale_by_date_summery"  />
                    </p:commandButton>
                    <p:commandButton ajax="false" value="Print" styleClass="noPrintButton" >
                        <p:printer target="panelPrint" />
                    </p:commandButton>
                </h:panelGrid>

                <h:panelGrid styleClass="printBlock" columns="2">
                    <h:outputLabel />
                    <h:outputLabel value="LAB HAND OVER REPORT SUMMERY"/>                   
                    <h:outputLabel value="From Date :  "/>
                    <h:outputLabel value="#{bookKeepingSummery.fromDate}"  >
                        <f:convertDateTime pattern="dd MMMM yyyy" />
                    </h:outputLabel>
                    <h:outputLabel value="To Date"/>
                    <h:outputLabel value="#{bookKeepingSummery.toDate}"  >
                        <f:convertDateTime pattern="dd MMMM yyyy" />
                    </h:outputLabel>                       
                </h:panelGrid>
            </p:panel>
            <p:panel id="panelPrint" styleClass="noBorder summeryBorder">
                <p:dataTable id="sum1" value="#{pharmacySaleReport.billedSummery.bills}" var="i"
                             rows="20"
                             paginator="true"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             rowsPerPageTemplate="20, 50, 100" 
                             >   
                    <f:facet name="header">
                        <p:outputLabel value="#{bookKeepingSummery.institution.name} Summary Report By Date" />
                        <h:outputLabel value="From : "/>
                        <h:outputLabel value="#{bookKeepingSummery.fromDate}">
                            <f:convertDateTime pattern="dd MMMM yyyy HH:mm:ss a"/>
                        </h:outputLabel>
                        <h:outputLabel value="To :"/>
                        <h:outputLabel value="#{bookKeepingSummery.toDate}">
                            <f:convertDateTime pattern="dd MMMM yyyy HH:mm:ss a"/>
                        </h:outputLabel>
                    </f:facet>

                    <p:column headerText="Date"
                              sortBy="#{i.string}" 
                              filterBy="#{i.string}"
                              filterMatchMode="contains">
                        <f:facet name="header">
                            <h:outputLabel value="Date" />
                        </f:facet>
                        <h:outputLabel value="#{i.string}" />
                    </p:column>
                    <p:column headerText="Hospital Fee" styleClass="averageNumericColumn">
                        <f:facet name="header">
                            <h:outputLabel value="Hospital Fee" />
                        </f:facet>
                        <h:outputLabel value="#{i.value1}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column headerText="Regent Fee" styleClass="averageNumericColumn">
                        <f:facet name="header">
                            <h:outputLabel value="Regent Fee" />
                        </f:facet>
                        <h:outputLabel value="#{i.value2}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column headerText="Staff Fee" styleClass="averageNumericColumn">
                        <f:facet name="header">
                            <h:outputLabel value="Staff Fee" />
                        </f:facet>
                        <h:outputLabel value="#{i.value3}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column headerText="Net Value" styleClass="averageNumericColumn">
                        <f:facet name="header">
                            <h:outputLabel value="Net Value" />
                        </f:facet>
                        <h:outputLabel value="#{i.value1+i.value3}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>

                    <p:columnGroup type="footer">
                        <p:row>
                            <p:column footerText="Total  "/>
                            <p:column footerText="#{bookKeepingSummery.bksr.proFee}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{bookKeepingSummery.bksr.proFee}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                            <p:column footerText="#{bookKeepingSummery.bksr.reagentFee}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{bookKeepingSummery.bksr.reagentFee}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                            <p:column footerText="#{bookKeepingSummery.bksr.proFee}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{bookKeepingSummery.bksr.proFee}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                            <p:column footerText="#{bookKeepingSummery.bksr.hosFee+bookKeepingSummery.bksr.proFee+bookKeepingSummery.bksr.reagentFee}" style="text-align: right;">
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{bookKeepingSummery.bksr.hosFee+bookKeepingSummery.bksr.proFee+bookKeepingSummery.bksr.reagentFee}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                        </p:row>
                    </p:columnGroup>

                </p:dataTable>               

            </p:panel>
            <p:spacer height="30px"/>
            <p:panelGrid columns="2">
                <h:outputLabel value="Hospital Fee Total"/>
                <h:outputLabel value="#{bookKeepingSummery.bksr.hosFee}"/>

                <h:outputLabel value="Regent Fee Total"/>
                <h:outputLabel value="#{bookKeepingSummery.bksr.reagentFee}"/>

                <h:outputLabel value="Professional Fee Total"/>
                <h:outputLabel value="#{bookKeepingSummery.bksr.proFee}"/>               

                <h:outputLabel value="Net Total"/>
                <h:outputLabel value="#{bookKeepingSummery.bksr.hosFee + bookKeepingSummery.bksr.reagentFee + 
                                        bookKeepingSummery.bksr.proFee}"/>
            </p:panelGrid>


        </h:form>

    </ui:define>



</ui:composition>
